home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.applet.AudioClip;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.MediaTracker;
- import java.awt.image.FilteredImageSource;
- import java.awt.image.ImageObserver;
- import java.net.MalformedURLException;
- import java.net.URL;
-
- public class fphover extends Applet {
- private String m_image = "";
- private String m_hoverImage = "";
- private Color m_bgColor;
- private Color m_color;
- private Color m_hoverColor;
- private String m_effectString;
- private String m_sound;
- private String m_hoverSound;
- private String m_url;
- private String m_target;
- private String m_text;
- private Color m_textColor;
- private String m_textAlign;
- private String m_textVAlign;
- private String m_font;
- private String m_fontStyle;
- private int m_fontSize;
- private final String PARAM_image;
- private final String PARAM_hoverImage;
- private final String PARAM_bgColor;
- private final String PARAM_color;
- private final String PARAM_hoverColor;
- private final String PARAM_effect;
- private final String PARAM_sound;
- private final String PARAM_hoverSound;
- private final String PARAM_url;
- private final String PARAM_target;
- private final String PARAM_text;
- private final String PARAM_textColor;
- private final String PARAM_textAlign;
- private final String PARAM_textVAlign;
- private final String PARAM_font;
- private final String PARAM_fontStyle;
- private final String PARAM_fontSize;
- private int m_effect;
- private Image m_srcImage;
- private Image m_srcHoverImage;
- private AudioClip m_audio;
- private AudioClip m_hoverAudio;
- private URL m_docUrl;
- private int m_hover;
- private int m_textWidth;
- private boolean m_textMask;
- private Image m_textImage;
- private int m_iTextAlign;
- private int m_iTextVAlign;
- private int m_textImageWidth;
- private int m_textImageHeight;
- private boolean m_textImageError;
- private boolean m_srcImageError;
- private boolean m_srcHoverImageError;
- private boolean m_applyEffectWait;
- private FontMetrics m_fm;
- private static final int COLOR = 0;
- private static final int IMAGE = 1;
- private static final int EFFECT = 2;
- private int m_normalType;
- private int m_hoverType;
- private boolean m_noErase;
- private int m_w;
- private int m_h;
- private int m_x;
- private int m_y;
-
- public boolean mouseMove(Event var1, int var2, int var3) {
- return true;
- }
-
- public void stop() {
- }
-
- public boolean mouseEnter(Event var1, int var2, int var3) {
- this.m_hover = 1;
- if (this.m_hoverAudio != null) {
- this.m_hoverAudio.play();
- }
-
- ((Applet)this).showStatus(this.m_url);
- if (this.m_normalType != 1 || this.m_hoverType != 1 || !this.m_image.equals(this.m_hoverImage)) {
- ((Component)this).repaint();
- }
-
- return true;
- }
-
- public boolean mouseExit(Event var1, int var2, int var3) {
- this.m_hover = 0;
- if (this.m_normalType != 1 || this.m_hoverType != 1 || !this.m_image.equals(this.m_hoverImage)) {
- ((Component)this).repaint();
- }
-
- return true;
- }
-
- public void paint(Graphics var1) {
- this.getXY();
- if (this.m_hover == 0) {
- if (!this.m_srcImageError) {
- var1.drawImage(this.m_srcImage, 0, 0, this);
- }
- } else {
- if (!this.m_srcHoverImageError) {
- var1.drawImage(this.m_srcHoverImage, 0, 0, this);
- }
-
- if (this.m_effect == 5) {
- this.m_x += -1;
- this.m_y += -1;
- }
-
- if (this.m_effect == 6) {
- ++this.m_x;
- ++this.m_y;
- }
- }
-
- if (this.m_textMask) {
- if (!this.m_textImageError) {
- var1.drawImage(this.m_textImage, this.m_x, this.m_y, this);
- }
- } else {
- var1.setColor(this.m_textColor);
- var1.drawString(this.m_text, this.m_x, this.m_y);
- }
-
- }
-
- public boolean mouseUp(Event var1, int var2, int var3) {
- if (!this.m_url.equalsIgnoreCase("") && this.m_docUrl != null) {
- if (this.m_target.equalsIgnoreCase("")) {
- ((Applet)this).getAppletContext().showDocument(this.m_docUrl);
- } else {
- ((Applet)this).getAppletContext().showDocument(this.m_docUrl, this.m_target);
- }
- }
-
- if (this.m_audio != null) {
- this.m_audio.play();
- }
-
- return true;
- }
-
- public String[][] getParameterInfo() {
- String[][] var1 = new String[][]{{"image", "String", "Normal button image"}, {"hoverImage", "String", "Hover button image"}, {"bgColor", "int", "Background color"}, {"color", "int", "Normal color"}, {"hoverColor", "int", "Hover color"}, {"effect", "int", "Effect for hover image"}, {"sound", "String", "Sound Url"}, {"hoverSound", "String", "Hover sound Url"}, {"url", "String", "Url"}, {"target", "String", "Target frame"}, {"text", "String", "Text"}, {"textColor", "int", "Text color"}, {"textAlign", "String", "Text alignment"}, {"textVAlign", "String", "Text vertical alignment"}, {"font", "String", "Font"}, {"fontStyle", "String", "Font style"}, {"fontSize", "int", "Font size in points"}};
- return var1;
- }
-
- public void destroy() {
- }
-
- public fphover() {
- this.m_bgColor = Color.white;
- this.m_color = Color.white;
- this.m_hoverColor = Color.white;
- this.m_effectString = "";
- this.m_sound = "";
- this.m_hoverSound = "";
- this.m_url = "";
- this.m_target = "";
- this.m_text = "";
- this.m_textColor = Color.black;
- this.m_textAlign = "center";
- this.m_textVAlign = "middle";
- this.m_font = "Dialog";
- this.m_fontStyle = "bold";
- this.m_fontSize = 14;
- this.PARAM_image = "image";
- this.PARAM_hoverImage = "hoverImage";
- this.PARAM_bgColor = "bgColor";
- this.PARAM_color = "color";
- this.PARAM_hoverColor = "hoverColor";
- this.PARAM_effect = "effect";
- this.PARAM_sound = "sound";
- this.PARAM_hoverSound = "hoverSound";
- this.PARAM_url = "url";
- this.PARAM_target = "target";
- this.PARAM_text = "text";
- this.PARAM_textColor = "textColor";
- this.PARAM_textAlign = "textAlign";
- this.PARAM_textVAlign = "textVAlign";
- this.PARAM_font = "font";
- this.PARAM_fontStyle = "fontStyle";
- this.PARAM_fontSize = "fontSize";
- this.m_hoverType = 2;
- }
-
- public void getXY() {
- this.m_w = ((Component)this).size().width;
- this.m_h = ((Component)this).size().height;
- this.m_x = 0;
- this.m_y = 0;
- if (this.m_textMask) {
- if (this.m_textImageWidth < 0 || this.m_textImageHeight < 0) {
- return;
- }
-
- if (this.m_iTextAlign == 0) {
- this.m_x = (this.m_w - this.m_textImageWidth) / 2;
- } else if (this.m_iTextAlign == 1) {
- this.m_x = this.m_w - this.m_textImageWidth;
- }
-
- if (this.m_iTextVAlign == 0) {
- this.m_y = (this.m_h - this.m_textImageHeight) / 2;
- } else if (this.m_iTextVAlign == 1) {
- this.m_y = this.m_h - this.m_textImageHeight;
- }
- } else {
- this.m_x = (this.m_w - this.m_textWidth) / 2;
- this.m_y = (this.m_h + this.m_fm.getAscent() - this.m_fm.getDescent()) / 2;
- }
-
- }
-
- public void update(Graphics var1) {
- if (!this.m_noErase) {
- var1.clearRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
- }
-
- this.paint(var1);
- }
-
- public void start() {
- }
-
- public String getAppletInfo() {
- return "Name: fphover\r\n" + "Author: Tom Blumer\r\n" + "Created with Microsoft Visual J++ Version 1.1";
- }
-
- public boolean mouseDown(Event var1, int var2, int var3) {
- return true;
- }
-
- public void init() {
- String var1 = ((Applet)this).getParameter("image");
- if (var1 != null) {
- this.m_image = var1;
- }
-
- if (!this.m_image.equalsIgnoreCase("")) {
- this.m_normalType = 1;
- }
-
- var1 = ((Applet)this).getParameter("hoverImage");
- if (var1 != null) {
- this.m_hoverImage = var1;
- }
-
- if (!this.m_hoverImage.equalsIgnoreCase("")) {
- this.m_hoverType = 1;
- }
-
- var1 = ((Applet)this).getParameter("bgColor");
- if (var1 != null) {
- if (var1.charAt(0) == '#') {
- var1 = var1.substring(1);
- }
-
- this.m_bgColor = new Color(Integer.parseInt(var1, 16));
- }
-
- var1 = ((Applet)this).getParameter("color");
- if (var1 != null) {
- if (var1.charAt(0) == '#') {
- var1 = var1.substring(1);
- }
-
- this.m_color = new Color(Integer.parseInt(var1, 16));
- }
-
- var1 = ((Applet)this).getParameter("hoverColor");
- if (var1 != null) {
- if (var1.charAt(0) == '#') {
- var1 = var1.substring(1);
- }
-
- this.m_hoverColor = new Color(Integer.parseInt(var1, 16));
- }
-
- var1 = ((Applet)this).getParameter("effect");
- if (var1 != null) {
- this.m_effectString = var1;
- }
-
- this.m_effect = 2;
- if (this.m_effectString.equalsIgnoreCase("fill")) {
- this.m_effect = 0;
- } else if (this.m_effectString.equalsIgnoreCase("average")) {
- this.m_effect = 1;
- } else if (this.m_effectString.equalsIgnoreCase("glow")) {
- this.m_effect = 2;
- } else if (this.m_effectString.equalsIgnoreCase("reverseGlow")) {
- this.m_effect = 3;
- } else if (this.m_effectString.equalsIgnoreCase("lightglow")) {
- this.m_effect = 4;
- } else if (this.m_effectString.equalsIgnoreCase("bevelOut")) {
- this.m_effect = 5;
- } else if (this.m_effectString.equalsIgnoreCase("bevelIn")) {
- this.m_effect = 6;
- }
-
- var1 = ((Applet)this).getParameter("sound");
- if (var1 != null) {
- this.m_sound = var1;
- }
-
- var1 = ((Applet)this).getParameter("hoverSound");
- if (var1 != null) {
- this.m_hoverSound = var1;
- }
-
- var1 = ((Applet)this).getParameter("url");
- if (var1 != null) {
- this.m_url = var1;
- }
-
- var1 = ((Applet)this).getParameter("target");
- if (var1 != null) {
- this.m_target = var1;
- }
-
- var1 = ((Applet)this).getParameter("text");
- if (var1 != null) {
- this.m_text = var1;
- }
-
- var1 = ((Applet)this).getParameter("textColor");
- if (var1 != null) {
- if (var1.charAt(0) == '#') {
- var1 = var1.substring(1);
- }
-
- this.m_textColor = new Color(Integer.parseInt(var1, 16));
- }
-
- var1 = ((Applet)this).getParameter("textAlign");
- if (var1 != null) {
- this.m_textAlign = var1;
- }
-
- this.m_iTextAlign = 0;
- if (this.m_textAlign.equalsIgnoreCase("left")) {
- this.m_iTextAlign = -1;
- } else if (this.m_textAlign.equalsIgnoreCase("right")) {
- this.m_iTextAlign = 1;
- }
-
- var1 = ((Applet)this).getParameter("textVAlign");
- if (var1 != null) {
- this.m_textVAlign = var1;
- }
-
- this.m_iTextVAlign = 0;
- if (this.m_textVAlign.equalsIgnoreCase("top")) {
- this.m_iTextVAlign = -1;
- } else if (this.m_textVAlign.equalsIgnoreCase("bottom")) {
- this.m_iTextVAlign = 1;
- }
-
- var1 = ((Applet)this).getParameter("font");
- if (var1 != null) {
- this.m_font = var1;
- }
-
- this.m_textMask = this.m_font.equalsIgnoreCase("") || this.m_font.equalsIgnoreCase("TextMask");
- var1 = ((Applet)this).getParameter("fontStyle");
- if (var1 != null) {
- this.m_fontStyle = var1;
- }
-
- var1 = ((Applet)this).getParameter("fontSize");
- if (var1 != null) {
- this.m_fontSize = Integer.parseInt(var1);
- }
-
- ((Component)this).setBackground(this.m_bgColor);
- MediaTracker var2 = new MediaTracker(this);
- if (this.m_textMask) {
- this.m_textImage = ((Applet)this).getImage(((Applet)this).getDocumentBase(), this.m_text);
- var2.addImage(this.m_textImage, 1);
- } else {
- byte var3 = 0;
- if (this.m_fontStyle.equalsIgnoreCase("bold")) {
- var3 = 1;
- }
-
- if (this.m_fontStyle.equalsIgnoreCase("italic")) {
- var3 = 2;
- }
-
- if (this.m_fontStyle.equalsIgnoreCase("bolditalic")) {
- var3 = 3;
- }
-
- Font var4 = new Font(this.m_font, var3, this.m_fontSize);
- ((Component)this).setFont(var4);
- this.m_fm = ((Component)this).getFontMetrics(var4);
- this.m_textWidth = this.m_fm.stringWidth(this.m_text);
- }
-
- int var33 = ((Component)this).size().width;
- int var34 = ((Component)this).size().height;
- if (this.m_normalType == 1) {
- this.m_srcImage = ((Applet)this).getImage(((Applet)this).getDocumentBase(), this.m_image);
- var2.addImage(this.m_srcImage, 2);
- } else {
- this.m_srcImage = ((Component)this).createImage(var33, var34);
- Graphics var5 = this.m_srcImage.getGraphics();
- var5.setColor(this.m_color);
- var5.fillRect(0, 0, var33, var34);
- }
-
- if (this.m_hoverType == 1) {
- this.m_srcHoverImage = ((Applet)this).getImage(((Applet)this).getDocumentBase(), this.m_hoverImage);
- var2.addImage(this.m_srcHoverImage, 3);
- }
-
- try {
- var2.waitForAll();
- this.m_textImageError = var2.isErrorID(1);
- this.m_srcImageError = var2.isErrorID(2);
- this.m_srcHoverImageError = var2.isErrorID(3);
- } catch (InterruptedException var16) {
- }
-
- int var35 = this.m_srcImage.getWidth(this);
- int var6 = this.m_srcImage.getHeight(this);
- int var7 = var35;
- int var8 = var6;
- if (this.m_hoverType == 1) {
- var7 = this.m_srcHoverImage.getWidth(this);
- var8 = this.m_srcHoverImage.getHeight(this);
- }
-
- if (this.m_textMask) {
- this.m_textImageWidth = this.m_textImage.getWidth(this);
- this.m_textImageHeight = this.m_textImage.getHeight(this);
- }
-
- MediaTracker var9 = new MediaTracker(this);
- this.m_applyEffectWait = false;
- if (this.m_textMask && this.m_textColor != Color.black && !this.m_textImageError) {
- this.m_textImage = this.applyEffect(this.m_textImage, 7, this.m_textColor);
- var9.addImage(this.m_textImage, 3);
- this.m_applyEffectWait = true;
- }
-
- if (this.m_hoverType == 2) {
- this.m_srcHoverImage = this.applyEffect(this.m_srcImage, this.m_effect, this.m_hoverColor);
- var9.addImage(this.m_srcHoverImage, 2);
- this.m_applyEffectWait = true;
- }
-
- if (this.m_applyEffectWait) {
- try {
- var9.waitForAll();
- } catch (InterruptedException var15) {
- }
- }
-
- try {
- this.m_docUrl = new URL(((Applet)this).getDocumentBase(), this.m_url);
- } catch (MalformedURLException var14) {
- }
-
- if (!this.m_sound.equalsIgnoreCase("")) {
- this.m_audio = ((Applet)this).getAudioClip(((Applet)this).getDocumentBase(), this.m_sound);
- }
-
- if (!this.m_hoverSound.equalsIgnoreCase("")) {
- this.m_hoverAudio = ((Applet)this).getAudioClip(((Applet)this).getDocumentBase(), this.m_hoverSound);
- }
-
- if (var35 == var7 && var6 == var8 && var35 > 0 && var6 > 0) {
- this.m_noErase = true;
- Image var10 = ((Component)this).createImage(var35, var6);
- Graphics var11 = var10.getGraphics();
- var11.setColor(this.m_bgColor);
- var11.fillRect(0, 0, var35, var6);
- var11.drawImage(this.m_srcImage, 0, 0, (ImageObserver)null);
- this.m_srcImage = var10;
- Image var12 = ((Component)this).createImage(var35, var6);
- Graphics var13 = var12.getGraphics();
- var13.setColor(this.m_bgColor);
- var13.fillRect(0, 0, var35, var6);
- var13.drawImage(this.m_srcHoverImage, 0, 0, (ImageObserver)null);
- this.m_srcHoverImage = var12;
- }
-
- }
-
- public boolean mouseDrag(Event var1, int var2, int var3) {
- return true;
- }
-
- public Image applyEffect(Image var1, int var2, Color var3) {
- int var6 = ((Component)this).size().width;
- int var7 = ((Component)this).size().height;
- fphoverx var5 = new fphoverx(var6, var7, var3, var2);
- FilteredImageSource var8 = new FilteredImageSource(var1.getSource(), var5);
- Image var4 = ((Component)this).createImage(var8);
- return var4;
- }
- }
-